<%@include file="../common.jsp" %>

<script type="text/javascript">
	$(document).ready( function(){
		 setWorkFlowURL('<c:out value="${flowExecutionUrl}" />');
		 
		 $("#docType").val('<c:out value="${docType}"></c:out>');
		 $("#docStatus").val('<c:out value="${docStatus}"></c:out>');
		 $("#docWfStatus").val('<c:out value="${docWfStatus}"></c:out>');
		 
		 $("#company").val('<c:out value="${company}"></c:out>');
		 $("#businessUnit").val('<c:out value="${businessUnit}"></c:out>');
	});
</script>
<c:choose>
	<c:when test="${fn:length(workFlowList) eq 0}">
		<table style="width: 95%;">
			<tr align="left">
				<td>
					<span>No Document Pending.</span>				
				</td>
			</tr>
		</table>
	</c:when>

	<c:otherwise>
		<div align="center">
			<table class="resultsTable" style="width: 95%; table-layout: fixed; white-space: normal;" >
				<tr>
					<td>
						<form id="taskListForm">
						<table>
							<tr>
								<td class="spacingColumnWidthLess"></td>
								<td class="formLabel"> Type: </td>
								<td class="spacingColumnWidthLess"></td>
								<td class="formfield">
									<select name="docType" id="docType">
										<option value="0"> ALL </option>
									<c:forEach items="${docTypeMap}" var="docTypeMap">
										<option value="${docTypeMap.key}">${docTypeMap.value}</option>
									</c:forEach>
									</select>
								</td>
								<td class="spacingColumnWidthLess"></td>
								<td class="formLabel"> Doc Status: </td>
								<td class="spacingColumnWidthLess"></td>
								<td class="formField">
									<select name="docStatus" id="docStatus">
										<option value="ALL"> ALL </option>
									<c:forEach items="${docStatusSet}" var="docStatusSet">
										<option value="${docStatusSet}">${docStatusSet}</option>
									</c:forEach>
									</select>
								</td>
								<td class="spacingColumnWidthLess"></td>
								<td class="formLabel"> WorkFlow Status: </td>
								<td class="spacingColumnWidthLess"></td>
								<td class="formField">
									<select name="docWfStatus" id="docWfStatus">
										<option value="ALL"> ALL </option>
									<c:forEach items="${wfStatusMap}" var="wfStatusMap">
										<option value="${wfStatusMap.key}">${wfStatusMap.value}</option>
									</c:forEach>
									</select>
								</td>
								
								<td class="spacingColumnWidthLess"></td>
								<td class="formLabel"> Company: </td>
								<td class="spacingColumnWidthLess"></td>
								<td class="formfield">
									<select name="company" id="company" onchange="loadLocForCompTaskList('company','businessUnit');">
										<option value="0"> ALL </option>
									<c:forEach items="${companyList}" var="company">
										<option value="${company.key}">${company.value}</option>
									</c:forEach>
									</select>
								</td>
								
								<td class="spacingColumnWidthLess"></td>
								<td class="formLabel"> Business Unit: </td>
								<td class="spacingColumnWidthLess"></td>
								<td class="formfield">
									<select name="businessUnit" id="businessUnit">
										<option value="0"> ALL </option>
									</select>
								</td>
								
								
								<td class="spacingColumnWidthLess"></td>
								<td class="spacingColumnWidthLess"></td>
								<td> <input type="button" value="SEARCH" class="formButton ui-corner-all" 
										onclick="filterTaskList('taskListForm');"> </td>
							</tr>
						</table>
						</form>
					</td>
				</tr>
				<tr class="tableMainHeaderColor tableMainHeaderFont" style="width: 100%;" align="left">
					<td>
						<span class="searchResultsCaption">&nbsp;&nbsp;SEARCH RESULTS</span>
					</td>
				</tr>
				<tr>
					<td>
						<table class="viewDetails">
							<tr class="heading">
								<td> <span> Name </span> </td>
								<td> <span> Type </span> </td>
								<td> <span> Category </span> </td>
								<td> <span> Sub-Category </span> </td>
								<td> <span> Department </span> </td>
								<td> <span> Location </span> </td>
								<td> <span> User </span> </td>
								<td> <span> WorkFlow Status </span> </td>
								<td> <span> Doc Renewal Date </span> </td>
								<td> <span> Overdue by (days) </span> </td>
								<td> <span> Upload Date </span> </td>
								<td> <span> Company </span> </td>
								<td> <span> Remarks</span> </td>
							</tr>
							<c:forEach items="${workFlowList}" var="workflowItem" varStatus="loop">
								<c:set var="tabColor" value="even"></c:set>
						     	<c:if test="${(loop.index % 2) eq 0}">
						        	<c:set var="tabColor" value="odd"></c:set>
						        </c:if>
						        
								<tr class="${tabColor}">
									<td>
										<a href="javascript:viewDocumentWorkflow('${workflowItem.docId}','${workflowItem.wfId}','${workflowItem.wfStatus}');"><c:out value="${docGeneralDetailsList[loop.index].docName}"></c:out></a>
								 	</td>
									<td>
										<c:out value="${docGeneralDetailsList[loop.index].docType}"></c:out>
									</td>
									
									<td><c:out value="${docGeneralDetailsList[loop.index].docCategory}"></c:out></td>
									<td><c:out value="${docGeneralDetailsList[loop.index].docSubCategory}"></c:out></td>
									<td><c:out value="${docGeneralDetailsList[loop.index].docDepartment}"></c:out></td>
									<td><c:out value="${docGeneralDetailsList[loop.index].docLocation}"></c:out></td>
									<td>${workflowItem.strCreatedAuthor}</td>
									<td>
										<c:if test="${workflowItem.wfStatus eq 'PFS'}">Pending For Submission</c:if>
										<c:if test="${workflowItem.wfStatus eq 'PFR'}">Pending For Review</c:if>
										<c:if test="${workflowItem.wfStatus eq 'PFA'}">Pending For Approval</c:if>
										<c:if test="${workflowItem.wfStatus eq 'PFRR'}">Pending For Re-Review</c:if>
										<c:if test="${workflowItem.wfStatus eq 'PFRS'}">Pending For Re-Submission</c:if>
										<c:if test="${workflowItem.wfStatus eq 'PFRW'}">Pending For Renewal</c:if>
									</td>
									
									<td>
										<fmt:formatDate value="${docGeneralDetailsList[loop.index].docValidityEndDate}" type="date" pattern="<%=com.gss.common.util.ApplicationConstants.DEFAULT_DATE_PATTERN%>" />
									</td>
									<td><c:out value="${docGeneralDetailsList[loop.index].overDueByDays}"></c:out> </td>
									<td>
										<fmt:formatDate value="${docGeneralDetailsList[loop.index].createdDate}" type="date" pattern="<%=com.gss.common.util.ApplicationConstants.DEFAULT_DATE_PATTERN%>" />
									</td>
									<td>  <c:out value="${docGeneralDetailsList[loop.index].companyName}"></c:out> </td>
									<td> ${workflowItem.creatorRemarks} </td>
								</tr>
							</c:forEach>
						</table>
					</td>
				</tr>
			</table>	
		</div>
	</c:otherwise>
</c:choose>